import * as THREE from 'three';
import { MTLLoader } from 'three/examples/jsm/loaders/MTLLoader';
import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader';
export default async function (MTLpath: string, OBJpath: string): Promise<[THREE.Group, MTLLoader.MaterialCreator]> {
  const objLoader = new OBJLoader(),
    mtlLoader = new MTLLoader();

  const m = await mtlLoader.loadAsync(MTLpath);

  objLoader.setMaterials(m);
  const g = await objLoader.loadAsync(OBJpath);

  for (const i in m.materials) {
    const e = m.materials[i];
    // @ts-expect-error
    e.specular = new THREE.Color(0xff0000);

    // @ts-expect-error
    e.map.magFilter = THREE.NearestFilter;
    // @ts-expect-error
    e.map.minFilter = THREE.NearestFilter;
    e.needsUpdate = true;
  }
  return [g, m];
}
